import 'dart:io';

import 'package:archive/archive_io.dart';
import 'package:flutter/cupertino.dart';
import 'package:permission_handler/permission_handler.dart';

class GiraffeUtils {
  // 压缩文件
  static Future<File> zip(List<File> targetFiles, String zipPath) async {
    var encoder = ZipFileEncoder();
    encoder.create(zipPath);
    for (var item in targetFiles) {
      encoder.addFile(item);
    }
    encoder.close();
    return File(zipPath);
  }

  static Future<List<Permission>> checkPermissionNotGranted(Map<Permission, PermissionStatus> result) async {
    List<Permission> unPermission = [];
    for (Permission perKey in result.keys) {
      bool isGranted = await perKey.isGranted;
      debugPrint("$perKey, $isGranted");
      if (!isGranted) {
        unPermission.add(perKey);
      }
    }
    debugPrint('checkPermissionNotGranted: $unPermission');
    return unPermission;
  }
}